$(document).ready(function () {

    $("#registerform").validate({
        rules:{
            u_name:{
                required:true,
                minlength:4,
                maxlength:8

            },
            u_pwd:{
                required:true,
                minlength:4,
                maxlength:8

            },
            re_u_pwd:{
                required:true,
                equalTo:"[name='u_pwd']"
            }

        },
        messages:{
            u_name:{
                required:"用户名不能为空",
                minlength:"最少写四位",
                maxlength:"不能超过8位"

            },
            u_pwd:{
                required:"密码不能为空",
                minlength:"最少写四位",
                maxlength:"不能超过8位"

            },
            re_u_pwd:{
                required:"确认密码不能为空",
                equalTo:"两次密码不一致!"
            }

        }

    });

    $("#gotologin").click(function () {
        $(location).attr("href","../index.html");
    });



    $("#u_name").blur(function () {
        $.ajax({
            type:"post",
            url:"user/CheckUserName",
            dataType:"json",
            data:{
                u_name:$("#u_name").val(),
            },
            success:function (result) {
                var errorCode = result.errorCode;
                console.info(errorCode);
                if (errorCode==0){
                    $("#errorLog").addClass("hidden");
                }else{
                    var msg=result.status;
                    $("#errorLog").text(msg);
                    $("#errorLog").removeClass("hidden")
                }
            },
            error:function (er) {

            }
        });


    });


});